package com.example.myapplication;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;

import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import java.util.ArrayList;
import java.util.List;

// 聊天页面
public class Fragment1 extends Fragment {
    RecyclerView recyclerView;
    Myadapter2 ma;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState){
        View view=inflater.inflate(R.layout.fragment1, container, false);
        recyclerView=view.findViewById(R.id.recyclerView1);
        recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));

        // 把图片及其名称存入类Album
        List<Album> list = new ArrayList();
        Album thestorybegins = new Album(getRandomLengthName("The Story Begins"), R.drawable.tsb);
        list.add(thestorybegins);
        Album pagetwo = new Album(getRandomLengthName("Page Two"), R.drawable.cheerup);
        list.add(pagetwo);
        Album lane1 = new Album(getRandomLengthName("Twicecoaster:Lane1"), R.drawable.tt);
        list.add(lane1);
        Album lane2 = new Album(getRandomLengthName("Twicecoaster:Lane2"), R.drawable.knock);
        list.add(lane2);
        Album signal = new Album(getRandomLengthName("Signal"), R.drawable.sig);
        list.add(signal);
        Album twicetagram = new Album(getRandomLengthName("Twicetagram"), R.drawable.likey);
        list.add(twicetagram);
        Album merryhappy = new Album(getRandomLengthName("Merry&Happy"), R.drawable.mh);
        list.add(merryhappy);
        Album whatislove = new Album(getRandomLengthName("What Is Love"), R.drawable.wil);
        list.add(whatislove);
        Album summernights = new Album(getRandomLengthName("Summer Nights"), R.drawable.sn);
        list.add(summernights);
        Album yesoryes = new Album(getRandomLengthName("YES or YES"), R.drawable.yoy);
        list.add(yesoryes);
        Album fancyyou = new Album(getRandomLengthName("FANCY YOU"), R.drawable.fancy);
        list.add(fancyyou);
        Album feelspecial = new Album(getRandomLengthName("Feel Special"), R.drawable.fs);
        list.add(feelspecial);
        Album moremore = new Album(getRandomLengthName("MORE&MORE"), R.drawable.mm);
        list.add(moremore);
        Album eyeswideopen = new Album(getRandomLengthName("Eyes Wide Open"), R.drawable.ewo);
        list.add(eyeswideopen);
        Album tasteoflove = new Album(getRandomLengthName("Taste Of Love"), R.drawable.tol);
        list.add(tasteoflove);
        Album formulaoflove = new Album(getRandomLengthName("Formula Of Love:O+T=<3"), R.drawable.fol);
        list.add(formulaoflove);
        Album between12 = new Album(getRandomLengthName("BETWEEN 1&2"), R.drawable.ttt);
        list.add(between12);
        Album readytobe = new Album(getRandomLengthName("READY TO BE"), R.drawable.rtb);
        list.add(readytobe);

        // 适配器
        ma=new Myadapter2(list);
        recyclerView.setAdapter(ma);

        return view;
    }
    // 将专辑名转换为string
    private String getRandomLengthName(String name){
        StringBuilder builder = new StringBuilder();
        for (int i = 0; i < 1; i++) {
            builder.append(name);
        }
        return builder.toString();
    }
}
